{echo:JS::import("form")}
{echo:JS::import('dialog?skin=tinysimple');}
{echo:JS::import('dialogtools');}
<link type="text/css" rel="stylesheet" href="{url:#css/ucenter.css}" />
<style type="text/css">
td{text-align:center;}
</style>
<div class="container clearfix">
	{widget:name=sub_navs action=ucsidebar sidebar=$sidebar act=$actionId}
	<div class="content clearfix uc-content">
		<!-- 
		<h1 class="title"><span>账户金额管理：</span></h1>
		-->
		
		<div class="mt10 tab">
			<ul class="tab-head">
				
				<li>充值扣款记录<i></i></li>
				
			</ul>
			<div class="tab-body">
				
				
				<!-- 充值扣款 -->
				<div>
					<table class="simple">
						<tr>
							<th style="width:140px">时间</th>
							<th>金额</th>
							<th>操作类型</th>
							<th>账户类型</th>
							<th>操作人</th>
						</tr>
						{query:name=recharge where=user_id eq '$user[id]' page=1 order=id desc id=$zz}
						<tr class="{if:$key%2==1}odd{else:}even{/if}" align='center'>
							<td>{$item['create_time']}</td> 
							<td>{$item['je']}</td>
							<td>
								{if:$item['type']==0}
					        		<b class="green">充值</b>
					        	{elseif:$item['type']==1}
					        		<b class="red">扣款</b>
					        	{/if}
							</td>
							<td>{echo:Common::get_account_name($item['account_type'])}</td>
							<td>{$item['admin']}</td>
						</tr>
						{/query}
					</table>
					<div class="page-nav f12">{echo:$zz->pagebar()}</div>
				</div>
				
				
				
				
				
			</div>
		</div>
	</div>
</div>
<div id="recharge-dialog" class="hidden">
	<form action="{url:/payment/dopay}" method="post" target="_blank" callback="close_dialog">
		<table class="form" style="width:500px;">
			<tr>
				<td class="label">充值金额：</td>
				<td><input type="text" name="recharge"  pattern="float" alt="最小金额不小于0.01"> <label></label></td>
			</tr>
			<tr>
				<td class="label">支付方式：</td>
				<td><select name="payment_id">
					{query:name=payment as py fields=py.* join= left join pay_plugin as pp on py.plugin_id eq pp.id where=pp.class_name ne 'balance' and pp.class_name ne 'received' order=sort desc}
					<option value="{$item['id']}">{$item['pay_name']}</option>
					{/query}
				</select></td>
			</tr>
			<tr>
				<td colspan="2" class="tc"><input type="submit" class="btn" value="立刻充值"></td>
			</tr>
		</table>
	</form>
</div>
<div id="zh-dialog" class="hidden">
	 
	<table class="simple">
		<tr><td>现金币</td><td>借款币</td><td>购物币</td><td>重消币</td><td>信用币</td><td>学习币</td></tr>
		<tr class="red"><td>{$customer['balance']|'0.00'}</td><td>{$customer['jkb']|'0.00'}</td><td>{$customer['gwb']|'0'}</td><td>{$customer['cx']|'0.00'}</td><td>{$customer['xyb']|'0'}</td><td>{$customer['xxb']|'0'}</td></tr>
	</table>
	
	<form id="zh_form" action="{url:/ucenter/zh}" method="post" target="_blank" callback="submit_zh">
		<table class="form" style="width:600px;">
			<tr>
				<td >转换方式：</td>
				<td>
				<select name="zh_from" id="zh_from">
					<option value="balance">现金币</option>
					<option value="jkb">借款币</option>
					<option value="cx">重消币</option>
				</select> >> 
				<select name="zh_get" id="zh_get">
					<option value="gwb">购物币</option>
					<option value="xyb">信用币</option>
					<option value="xxb">学习币</option>
				</select><span class="f12 red">&nbsp;&nbsp;&nbsp;转学习币为1：2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;转购物币为1：3</span>
				</td>
			</tr>
			<tr>
				<td >转换金额：</td>
				<td><input type="text" name="amount" id="amount" pattern="float" alt="最小金额不小于0.01"> <label></label></td>
			</tr>
			<tr>
				<td >二级密码：</td>
				<td><input type="password" name="pass2" id="pass2" pattern="required" alt="输入二级密码"> <label></label></td>
			</tr>
			<tr>
				<td colspan="2" class="tc"><input type="submit" class="btn btn-main" value="开始转换"></td>
			</tr>
		</table>
	</form>
</div>
<!-- 转账 -->
<div  id="zz-dialog" class="hidden">
<form id="zz_form" action="{url:/ucenter/zz}" method="post" target="_blank" callback="submit_zz">
	<table class="form" style="width:600px;">
		<tr>
			<td class="label">账户金额：</td>
			<td> <label class="f18 red">{$currency_symbol}{$customer['balance']}</label></td>
		</tr>
		<tr>
			<td class="label">接收账号：</td>
			<td><input type="text" name="toname" id="toname" class="" pattern="name" alt="输入接收账号"> <label></label></td>
		</tr>
		<tr>
			<td class="label">转账额度：</td>
			<td><input type="text" id="amount" name="amount" class=""  pattern="float" min="10" alt="不能小于100"> <label>不能小于10元</label></td>
		</tr>
		<tr>
			<td class="label">备注：</td>
			<td><textarea name="bz"></textarea>
			<label></label></td>
		</tr>
		<tr>
			<td class="label">二级密码：</td>
			<td><input type="password" name="pass2" id="pass2" pattern="required" alt="输入二级密码"> <label></label></td>
		</tr>
		<tr>
			<td class="tc red f16" colspan="2">请认真核对好接收会员的正确编号！</td>
		</tr>
		<tr>
			<td colspan="2" class="tc"><input type="submit" class="btn" value="开始转账"></td>
		</tr>
	</table>
</form>
</div>
<div  id="withdraw-dialog" class="hidden">
	<form id="withdraw_form" action="{url:/ucenter/withdraw}" method="post" target="_blank" callback="submit_withdraw">
		<table class="form" style="width:600px;">
			<tr>
				<td class="label">账户金额：</td>
				<td> <label class="f18 red">{$currency_symbol}{$customer['balance']}</label></td>
			</tr>
			<tr>
				<td class="label">提现金额：</td>
				<td><input type="text" id="w_amount" name="amount" class="small"  pattern="float" min="1" max="{$customer['balance']}" alt="可提金额(1 - {$customer['balance']})"> <label></label></td>
			</tr>
			<tr>
				<td class="label">姓名：</td>
				<td><input type="text" id="w_name" name="name"  pattern="required" alt="开户对应的用户名"> <label></label></td>
			</tr>
			<tr>
				<td class="label">金融机构：</td>
				<td><input type="text" id="w_type_name" name="type_name"  pattern="required" alt="如（支付宝、中国银行）"> <label></label></td>
			</tr>
			<tr>
				<td class="label">金融账号：</td>
				<td><input type="text" id="w_account" name="account"  pattern="required" alt="如（支付宝账号、银行账号）"> <label></label></td>
			</tr>
			<tr>
				<td  class="label">二级密码：</td>
				<td><input type="password" name="pass2" id="pass2" pattern="required" alt="输入二级密码"> <label></label></td>
			</tr>
			<tr>
				<td colspan="2" class="tc"><input type="submit" class="btn" value="申请提现"></td>
			</tr>
		</table>
	</form>
</div>
<script type="text/javascript">
	$("#recharge-btn").on("click",function() {
		art.dialog({id:'recharge-dialog',title:'在线充值',content:document.getElementById('recharge-dialog'),lock:true});
	});
	$("#withdraw-btn").on("click",function() {
		art.dialog({id:'withdraw-dialog',title:'提现申请',content:document.getElementById('withdraw-dialog'),lock:true});
	});
	$("#zh-btn").on("click",function() {
		art.dialog({id:'zh-dialog',title:'币种转换',content:document.getElementById('zh-dialog'),lock:true});
	});
	$("#zz-btn").on("click",function() {
	art.dialog({id:'zz-dialog',title:'转账',content:document.getElementById('zz-dialog'),lock:true});
});
	function close_dialog(e){
		if(!e)art.dialog({id:'recharge-dialog'}).close();
	}
	function submit_withdraw(e){
		if(!e){
			var name = $("#w_name").val();
			var type_name = $("#w_type_name").val();
			var account = $("#w_account").val();
			var amount = $("#w_amount").val();
			var pass2 = $("#pass2").val();
			$.get("{url:/ucenter/withdraw}",{name:name,type_name:type_name,pass2:pass2,account:account,amount:amount},function(data){
				if(data['status']=='success'){
					art.dialog({id:'withdraw-dialog'}).close();
					art.dialog.tips("<p class='"+data['status']+"'>"+data['msg']+"</p>",2);
            		setTimeout("tools_reload()",2000);
					window.location.href = "{url:/ucenter/account/rand/}"+Math.random()+"#tab-3";
				}else{
					alert(data['msg']);
				}
			},'json');
		}
		return false;
	}
	function submit_zh(e){
		if(!e){
			var zh_get = $("#zh_get").val();
			var zh_from = $("#zh_from").val();
			var pass2 = $("#pass2").val();
			var amount = $("#amount").val();
			$.get("{url:/ucenter/zh}",{zh_get:zh_get,zh_from:zh_from,pass2:pass2,amount:amount},function(data){
				if(data['status']=='success'){
					art.dialog({id:'zh-dialog'}).close();
					art.dialog.tips("<p class='"+data['status']+"'>"+data['msg']+"</p>",2);
            		setTimeout("tools_reload()",2000);
					window.location.href = "{url:/ucenter/account/rand/}"+Math.random()+"#tab-2";
				}else{
					alert(data['msg']);
				}
			},'json');
		}
		return false;
	}
	function submit_zz(e){
	if(!e){
		var fields = $("#zz_form").serializeArray();
		$.get("{url:/ucenter/zz}",fields,function(data){
			if(data['status']=='success'){
				art.dialog({id:'zz-dialog'}).close();
				art.dialog.tips("<p class='"+data['status']+"'>"+data['msg']+"</p>",2);
            setTimeout("tools_reload()",2000);
            window.location.href = "{url:/ucenter/account/rand/}"+Math.random()+"#tab-1";
			}else{
				alert(data['msg']);
			}
		},'json');
	}
	return false;
}
</script>
